home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
8614
/
8614.xpi
/
modules
/
utils
/
Events.jsm
next >
Wrap
Text File
|
2010-02-10
|
1KB
|
52 lines
// DO NOT import this into the global namespace, but instead
// import it into your own namespace wrapper
var EXPORTED_SYMBOLS = ["EventSource"];
Components.utils.import("resource://glydo/utils/prototype_xul_1_6_0_3_modified.jsm");
var EventSource = Prototype.Class.create({
initialize: function() {
this.listeners = [];
},
addListener: function(listener) {
if (listener) {
this.listeners.push(listener);
}
},
removeListener: function(listener) {
var found = null;
for (var i = 0; i < this.listeners.length; ++i) {
if (this.listeners[i] === listener) {
found = i;
}
}
if (found !== null) {
this.listeners.splice(found,1);
}
},
fire: function(callback) {
var args = Prototype.$A(arguments);
args.shift();
if (callback) {
for (var index = 0; index < this.listeners.length; ++index) {
var listener = this.listeners[index];
try {
if (listener[callback])
listener[callback].apply(listener,args);
} catch (ex) {
if (Components) {
Components.utils.reportError(ex);
} else {
throw ex;
}
}
}
}
}
});